using UnityEngine;
using System.Collections;

public class PruebaMovimientoScript : MonoBehaviour {
	
	
	public Camino path;
	public Transform personaje;
	// Use this for initialization
	
	private float moving;
	private float dist;
	
	private bool ping;
	private bool pong;
	void Start () {
	moving=0.0f;
	
		ping=true;
		pong=false;
	}
	
	// Update is called once per frame
	void Update () {
		
	
		personaje.transform.position = path.CalculatePathPoint(moving);
		
			//moving=moving+Input.GetAxis("Horizontal")*0.5f;
			Debug.Log(personaje.transform.position);
		//if (moving>=path.NotDinamicLength || moving<0 )
		//	moving=0f;
		if(moving<0 || moving>=path.NotDinamicLength)
		{
			ping=!ping;
			pong=!pong;
		}
		
		
		if(ping)
			moving=moving+0.7f;
		if (pong)
			moving=moving-0.7f;
		
	}
}
